<?php
session_start();
require("functions.php");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>查看我的购物车</title>	
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body{
	font-family:微软雅黑;
	font-size:16px;
	color:#036;
	}
  .cart_con{
  margin-top:30px;
}
  .div_glo_con{
    margin-top:20px;
  }
</style>
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container div_glo_con">
    <?php
/*    echo "<pre>";
      print_r($_SESSION['shopList']);
      echo "</pre>";*/
    ?>
          <?php 
          if (!empty($_SESSION['shopList']))
          {
            ?>
        <table class="table table-hover">
        <tbody>
          <tr class="info">
            <td>商品图片</td><td>商品</td><td>商品信息</td><td>单价</td><td>数量</td>
            <td>总价钱</td>
            <td>操作</td>
          </tr>
            <?php
            $color_arr = array(1 => "error", 2 => "warning", 3 => "success");
            $i = 1;  //
            $goods_num = 0; //记录商品个数
            $sum = 0; //购物车中商品总金额
            foreach ($_SESSION['shopList'] as $key => $value) 
            {
          ?>
               <tr class="<?php echo $color_arr[$i];?>">
                 <td><img src="./uploads/s_<?php echo $value['pic'];?>" class="img-rounded"></td>
                 <!--此处调用了一个函数，去让商品的信息换行显示-->
                 <td><?php echo getLimitString($value['name'], 14); ?></td><td><?php echo $value['sizeCode']; 
                 echo "<br />";echo "长度： ".$value['longth']." cm<br />"; echo "宽度：".$value['width']." cm";?></td>
                 <td><?php echo $value['price']; ?>&nbsp;&yen;</td><td><?php echo $value['total']."件"; ?></td>
                 <td><?php echo $value['price']*$value['total']; ?>.00&nbsp;&yen;</td>
                 <td><a href="clearCart.php?IDTEM=<?php echo $key;?>" class="btn btn-danger">删除</a></td>
               </tr>
          <?php
               if ($i % 3 == 0)
               {
                 $i = 1;
               }
               else
               {
                  $i++;
               }
               $sum += $value['price']*$value['total'];
               $goods_num++;
            }

          ?>
       </tbody>
       <tr><td><p class="text-success">您的购物车中当前商品数量有&nbsp;<strong><?php echo $goods_num;?></strong>&nbsp;</p></td></tr>
      </table>
      <div class="row">
        <div class="span4 offset1">
          <h3>总金额：<span style="color:red; font-size:30px;"><?php echo $sum.".00"."&nbsp;&yen;";?></span></h3>
          <p><a class="btn btn-primary btn-large">结算</a><br /><br />
          <a href="homePage.php" class="btn btn-inverse">返回搜索页</a>
          </p>
          
        </div>
        <div class="span3 offest1">
            <br />
            <p class="muted">购物是一种态度，所以力求简单！为用户打造非一般地体验，是我们不竭的追求！
              不求最好，但求更好。享受生活，享受购物所带来的乐趣！^_^^_^<br />
            </p>
        </div>
      </div>       
<?php
        }
        else
        {
          echo "<div class=\"alert cart_con\">";
          echo "亲爱的，您当前<strong>未添加商品到购物车</strong>哦！快去<a href=\"homePage.php\" 
          class=\"btn btn-inverse\">主页</a>找宝贝吧！";
          echo "</div>";
        }

?>          
</div>
<script src="./bootstrap/js/bootstrap.min.js"></script>
<script src="./js/jquery-1.9.1.min.js"></script>
</body>
</html>
    



